<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>驳回原因</title>
		<link href="asserts/css/bootstrap.min.css" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="asserts/css/dashboard.css" rel="stylesheet">

	</head>

	<body>

	<div th:insert="common/bar::top"></div>

		<div class="container-fluid">
			<div class="row">
				<div th:insert="common/bar::#left"></div>
				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<div class="table-responsive">
						<form id="myForm">
							<div class="form-group">
								<label>证件号</label>
								<input id="drivingLicenseID" name="drivingLicenseID" type="text" class="form-control"
									   th:value="${session.drivingLicenseID}" disabled>
							</div>
							<div class="form‐group">
								<label>驳回原因</label>
								<input name="rejectReason" id="reason"  type="text" class="form-control" placeholder="">
								<a  id="a-reason"  th:text="请填写驳回原因" style="color: red;visibility: hidden"></a>
							</div>
						</form>
						<button type="submit" class="btn btn-primary" onclick="correctReject()">确认驳回</button>
					</div>
				</main>
			</div>
			<a type="hidden" id="cancelApplicationMessage" th:text="${session.cancelApplicationMessage eq null ? 'null' : session.cancelApplicationMessage}"></a>

		</div>

	<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script src="asserts/js/popper.min.js"></script>
	<script src="asserts/js/feather.min.js"></script>
	<script src="asserts/js/bootstrap.min.js"></script>

		<script>
			window.onload=function() {

			}

			function correctReject() {

				var reason = document.getElementById("reason").value;
				console.log(reason.length);
				if(reason.length<1){
					console.log("请填写驳回原因");
					document.getElementById("a-reason").style.visibility="visible";
				}else{
					document.getElementById("a-reason").style.visibility="hidden";
				}
				console.log("reason");
				console.log(reason);

				alert("确定驳回吗？");
				var form = new FormData(document.getElementById("myForm"));
				console.log(form);
				form.append("drivingLicenseID",document.getElementById("drivingLicenseID").value);
				$.ajax({
					url:"rejectDrivingLicenseApplication.do",
					type:"post",
					dataType:"html",
					data:form,
					cache:false,
					processData:false,
					contentType:false,
					success: function (data) {
						console.log("success");
						alert("操作成功！");
						location.href="getCancelDrivingLicenseApplication.do";
					},
					error:function (data) {
						alert("提交失败");
						console.log("error");
						location.href="404";
					}
				})

			}


		</script>


	</body>

</html>